//
//  UIButton+Extension.swift
//  iOSWeibo11
//
//  Created by Apple on 16/7/24.
//  Copyright © 2016年 Apple. All rights reserved.
//

import UIKit

extension UIButton {
    
    /**
     创建一个按钮
     
     - parameter image:      按钮图片
     - parameter title:      按钮文字
     - parameter titleColor: 按钮文字颜色
     - parameter titleFont:  按钮文字大小
     - parameter bkgImage:   背景图片
     
     - returns:
     */
    convenience init(imageName: String, title: String, titleColor: UIColor = UIColor.darkGrayColor(), titleFont: CGFloat = 15, bkgImageName: String = "timeline_card_bottom_background") {
        self.init()
        
        self.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        self.setTitle(title, forState: UIControlState.Normal)
        self.setTitleColor(titleColor, forState: UIControlState.Normal)
        self.titleLabel?.font = UIFont.systemFontOfSize(titleFont)
        self.setBackgroundImage(UIImage(named: bkgImageName), forState: UIControlState.Normal)
        self.setBackgroundImage(UIImage(named: bkgImageName + "_highlighted"), forState: UIControlState.Highlighted)
    }
}
